package com.devilvan.betrice.aiqicha.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.devilvan.betrice.aiqicha.dto.AiqichaLicenseDto;
import com.devilvan.betrice.aiqicha.po.AiqichaLicensePo;
import com.devilvan.betrice.aiqicha.service.AiqichaLicenseService;
import com.devilvan.betrice.aiqicha.mapper.AiqichaLicenseMapper;
import com.devilvan.betrice.aiqicha.repository.AiqichaLicenseRepository;
import com.devilvan.betrice.util.UCopy;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
* @author Evad.Wu
* @Description 爱企查-行政许可信息 业务逻辑类
* @date 2022-09-24
*/
@Service
public class AiqichaLicenseServiceImpl extends ServiceImpl<AiqichaLicenseMapper, AiqichaLicensePo> implements AiqichaLicenseService {
    @Resource(name = "aiqichaLicenseRepository")
    private AiqichaLicenseRepository aiqichaLicenseRepository;

    @Override
    public AiqichaLicensePo saveUpdate(AiqichaLicenseDto aiqichaLicenseDto) {
        AiqichaLicensePo aiqichaLicensePo = new AiqichaLicensePo();
        UCopy.fullCopy(aiqichaLicenseDto, aiqichaLicensePo);
        return aiqichaLicenseRepository.saveAndFlush(aiqichaLicensePo);
    }

    @Override
    public List<AiqichaLicensePo> saveUpdateBatch(List<AiqichaLicenseDto> list) {
        List<AiqichaLicensePo> aiqichaLicensePoList = UCopy.fullCopyCollections(list, AiqichaLicensePo.class);
        return aiqichaLicenseRepository.saveAllAndFlush(aiqichaLicensePoList);
    }

    @Override
    public List<AiqichaLicensePo> findAllList() {
        return this.list();
    }
}
